

package CtrLayer;
import ModelLayer.*;
import DBLayer.*;

import java.util.ArrayList;

public class ProductCtr {
   
    
    /** Creates a new instance of CustomerCtr */
    public ProductCtr() {
        
    }
    public ArrayList<Product> findAllProducts()
    {
      IFDBProduct dbProduct = new DBProduct();
      ArrayList<Product> allProducts = new ArrayList<Product>();
      allProducts = dbProduct.getAllProducts(false);
      return allProducts;
    }
    public Product findByName(String name)
    {
        IFDBProduct dbProduct = new DBProduct();
        return dbProduct.searchProductName(name, true);
    }
   
      public Product findByProductID(int ProductID)
    {
        IFDBProduct dbProduct = new DBProduct();
        return dbProduct.searchProductID( ProductID, true);
    }
      public int updateProduct(int productID, String name, double purchasePrice,
  			double salesPrice, double rentPrice, String countryOfOrigin,
  			int minStock, int size, String colour, String pType,
  			String pDescription, String fabric, String calibre)
      {
          IFDBProduct dbProduct = new DBProduct();
          Product pro = new Product();
          pro.setProductID(productID);
          pro.setName(name);
          pro.setPurchasePrice(purchasePrice);
          pro.setSalesPrice(salesPrice);
          pro.setRentPrice(rentPrice);
          pro.setCountryOfOrigin(countryOfOrigin);
          pro.setMinStock(minStock);
          pro.setSize(size);
          pro.setColour(colour);
          pro.setpType(pType);
          pro.setpDescription(pDescription);
          pro.setFabric(fabric);
          pro.setCalibre(calibre);
          return  dbProduct.updateProduct(pro);
          
          
      }
      
      
    
}